# -*- coding: utf-8 -*-

#   Copyright (C) 2011  P.L. Lucas, P.L. del Castillo
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygtk
pygtk.require('2.0')
import gtk

class FXDialog:
	def __init__(self, parent):
		self.dialog= gtk.Dialog("Properties", parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
		self.area=self.area_init()
		self.dialog.vbox.pack_start(self.area, True, True  )
	
	def run(self):
		self.area.show_all()
		res=self.dialog.run()
		if res==gtk.RESPONSE_ACCEPT:
			return True
		else:
			return False
	def close(self):
		self.dialog.destroy()
	
	def get_text(self,name,type_):
		return eval( type_+'(self.'+name+'_entry.get_text())' )
	
	def text_entry(self, label, name, value):
		area1=gtk.HBox()
		l=gtk.Label(label)
		area1.pack_start(l, False, False)
		eval( compile('self.'+name+'_entry=gtk.Entry()', '<string>', 'exec') )
		eval( compile('self.'+name+'_entry.set_text(str('+str(value)+'))', '<string>', 'exec') )
		eval( compile('area1.pack_start(self.'+name+'_entry, False, False)', '<string>', 'exec') )
		area1.show_all()
		self.area.pack_start(area1,False,False)
	
	def area_init(self):
		area=gtk.VBox()
		area.show_all()
		return area
	
	
